package com.lagou.edu.utils;

/**
 * @ClassName: ResolveUtils
 * @Auther: Jerry
 * @Date: 2020/7/7 23:26
 * @Desctiption: 字符串转换工具类
 * @Version: 1.0
 */
public class ResolveUtils {

    public static void main(String[] args) {
        String str = "com.lagou.edu.service.impl.ITransferService";
        String beanName = lowerFirstCase(str);
        System.out.println(beanName);
    }

    /**
     * 字符串首字母小写
     * 如果类名首字母包含I，做特殊处理
     * 例如：IAccountDao—>accountDao
     * @param str str
     * @return {@link String}
     */
    public static String lowerFirstCase(String str){
        String newStr = str.substring(str.lastIndexOf(".") + 1, str.length());
        if (newStr.contains("I")) {
            newStr = newStr.replaceFirst("I", "");
        }
        char[] chars = newStr.toCharArray();
        // 大写转小写
        chars[0] += 32;
        return String.valueOf(chars);
    }
}
